/* Ctors / Dtors */
template<typename T>
inline Vector2<T>::Vector2()
  : x(0.0), y(0.0)
{}

template<typename T>
inline Vector2<T>::Vector2(T X, T Y)
  : x(X), y(Y)
{}

template<typename T>
inline Vector2<T>::~Vector2()
{}


/* Operators */
/*|| += , -= , *= , /= ||*/
template<typename T>
inline Vector2<T>& Vector2<T>::operator +=(const Vector2& other)
{
  this->x += other.x;
  this->y += other.y;
  return *this;
}

template<typename T>
inline Vector2<T>& Vector2<T>::operator -=(const Vector2& other)
{
  this->x -= other.x;
  this->y -= other.y;
  return *this;
}

template<typename T>
inline Vector2<T>& Vector2<T>::operator *=(const Vector2& other)
{
  this->x *= other.x;
  this->y *= other.y;
  return *this;
}

template<typename T>
inline Vector2<T>& Vector2<T>::operator /=(const Vector2& other)
{
  // If other.x or other.y is zero, throw an exception.
  if (((other.x < 1E-7f) || (other.x > -1E-7f)) || ((other.y < 1E-7f) || (other.y > -1E-7f)))
    throw klas::error::Exception("Vector2<T> operator /=: attempt to divide by zero.");

  this->x /= other.x;
  this->y /= other.y;
  return *this;
}

/*|| + , - , * , / ||*/
template<typename T>
inline Vector2<T> Vector2<T>::operator +(const Vector2& lhs)
{
  return Vector2(this->x + lhs.x, this->y + lhs.y);
}

template<typename T>
inline Vector2<T> Vector2<T>::operator -(const Vector2& lhs)
{
  return Vector2(this->x - lhs.x, this->y - lhs.y);
}

template<typename T>
inline Vector2<T> Vector2<T>::operator *(const Vector2& lhs)
{
  return Vector2(this->x * lhs.x, this->y * lhs.y);
}

template<typename T>
inline Vector2<T> Vector2<T>::operator /(const Vector2& lhs)
{
  // If lhs.x or lhs.y is zero, throw an exception.
  if (((lhs.x < 1E-7f) || (lhs.x > -1E-7f)) || ((lhs.y < 1E-7f) || (lhs.y > -1E-7f)))
    throw klas::error::Exception("Vector2<T> operator /: attempt to divide by zero.");

  return Vector2(this->x / lhs.x, this->y / lhs.y);
}